<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Login_Model extends CI_Model{
    function __construct()
    {
        parent::__construct();
    }
    function get_admin($user_name,$password){
        $this->db->where('login_name',$user_name);
        $this->db->where('password',$password);
        $query = $this->db->get('admin');
          
        if($query->row()){
             $row=$query->row_array();
             $this->session->sess_destroy();
             $this->session->sess_create(); 
             //Set session data 
             $this->session->set_userdata($row);
            
            //Set logged_in to true
            $this->session->set_userdata(array('logged_in' => true));               
              return true;
        }else{
              return false;
        }          
    }
    function check_login($user_name,$password){
        $this->db->where('login_name',$user_name);
        $this->db->where('password',$password);
        $query = $this->db->get('admin');
        if($query->num_rows() > 0){
            return true;
        }
        else{
            return false;
        }
    }
}